package com.ymatou.iapi.csim.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.UpdateCsSessionCountBean;
import com.ymatou.iapi.csim.service.UpdateCsSessionCountCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CsimCallService;
import com.ymttest.database.model.ymt_csmaxsessioncount;
import com.ymttest.database.model.ymt_onlinecs;
import com.ymttest.database.sqlwapper.CSIM.ymt_csmaxsessioncountWapper;
import com.ymttest.database.sqlwapper.CSIM.ymt_onlinecsWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.MapUtil;
/**
*更新客服最大会话数
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_UpdateCsSessionCount{
	private static UpdateCsSessionCountBean updatecssessioncountBean;
	private static UpdateCsSessionCountCall updatecssessioncountCall;
	private CsimCallService service=new CsimCallService();
	private Integer csId=Integer.parseInt(EnvSetup.getData("csId").toString());
	private static ymt_csmaxsessioncountWapper csmaxsessioncount=new ymt_csmaxsessioncountWapper();
	
	private static ymt_onlinecsWapper onlinecsWapper=new ymt_onlinecsWapper();
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("更新客服最大会话数");
	}

	@Before
	public void caseUp() {
		updatecssessioncountBean=new UpdateCsSessionCountBean();
		updatecssessioncountCall=new UpdateCsSessionCountCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(updatecssessioncountCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCsSessionCount_001() {
		Logger.start(true,"更新客服最大会话数-ymt_onlinecs表中存在");
		try {
			Logger.comment("csId:"+csId);
			service.getOnlineCS(csId);
			updatecssessioncountBean.setCsId(csId);
			updatecssessioncountBean.setMaxSessionCount(10);
			updatecssessioncountCall.setData(updatecssessioncountBean);
			updatecssessioncountCall.callService();			
			
			Logger.verifyEquals("200", updatecssessioncountCall.getStatus(), "验证Status");
			Logger.verifyEquals("", updatecssessioncountCall.getMsg(), "验证Msg");
			Logger.verifyEquals("true", updatecssessioncountCall.getResult().get("Success").toString(), "验证Success");
			ymt_csmaxsessioncount model=csmaxsessioncount.selectByPrimaryKey(csId);
			Logger.verifyEquals(updatecssessioncountBean.getMaxSessionCount(), model.getMaxSessionCount(), "验证MaxSessionCount");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCsSessionCount_002() {
		Logger.start(true,"更新客服最大会话数-ymt_onlinecs表中不存在");
		try {
			Logger.comment("删除旧数据");
			onlinecsWapper.deleteBy(MapUtil.hashMap("CSId",csId));
			service.getOnlineCS(csId);
			updatecssessioncountBean.setCsId(csId);
			updatecssessioncountBean.setMaxSessionCount(10);
			updatecssessioncountCall.setData(updatecssessioncountBean);
			updatecssessioncountCall.callService();			
			
			Logger.verifyEquals("200", updatecssessioncountCall.getStatus(), "验证Status");
			Logger.verifyEquals("", updatecssessioncountCall.getMsg(), "验证Msg");
			Logger.verifyEquals("true", updatecssessioncountCall.getResult().get("Success").toString(), "验证Success");
			ymt_csmaxsessioncount model=csmaxsessioncount.selectByPrimaryKey(csId);
			Logger.verifyEquals(updatecssessioncountBean.getMaxSessionCount(), model.getMaxSessionCount(), "验证MaxSessionCount");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}